import Vue from 'vue'
import App from './App'
import utils from './utils/util'
import tim from './commen/tim/tim.js'
import commen from './commen/commen.js'
import TIM from 'tim-js-sdk'
import store from './store/index.js'

const checkIsVip = function checkIsVip() {
	return new Promise((resolve, reject) => {
		this.$utils.request("/api/member/is_user_vip", '', res => {
			if (res.code == 200) {
				resolve(res.data)
				uni.setStorageSync('vipInfo', res.data)
			} else {
				reject(res.message)
			}
		})
	})
}

const switchInfo = function wxSwitch(id) {
	let data = {
		id: id
	}
	return new Promise((resolve, reject) => {
		this.$utils.request('/api/config/switch', data, res => {
			if (res.code == 200) {
				resolve(res.data)
			} else {
				reject(res)
			}
		})
	})
}

import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"
Vue.component('uni-nav-bar', uniNavBar)

import videoCall from "@/pages/videoChat/call.vue"
Vue.component('video-chat', videoCall)

import voiceChatModal from '@/components/voice-chat-modal.vue'
Vue.component('voiceChatModal', voiceChatModal)


const systemInfo = uni.getStorageSync('stytemInfo')

Vue.config.productionTip = false
Vue.prototype.$utils = utils
Vue.prototype.tim = tim.tim //tim sdk 引入后生成的tim服务
Vue.prototype.$TIM = TIM //tim 的状态/事件 常量
Vue.prototype.$store = store
Vue.prototype.$commen = commen
Vue.prototype.$checkIsVip = checkIsVip
Vue.prototype.$systemInfo = systemInfo
Vue.prototype.$switchInfo = switchInfo
Vue.prototype.$img = (url) => {
	if (url.split("/")[2] == "2021-08-28") {
		return url;
	}
	if (url.split("/")[2] == "2021-08-30") {
		return url;
	}
	return 'https://sx.hualin688.com' + url;
}
uni.tim = tim.tim //tim sdk 引入后生成的tim服务
uni.$utils = utils
uni.$store = store
App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()
